import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';
import 'package:msh_checkbox/msh_checkbox.dart';

import '../../../style/app_colors.dart';
import '../../../widget/tips.dart';
import '../controllers/power_oning_controller.dart';

class PowerOningView extends GetView<PowerOningController> {
  const PowerOningView({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.device_page_bg_color,
      appBar: AppBar(
        leading: IconButton(
          icon: Image.asset('assets/images/ic_back2.png',width: 48.w,height: 48.h),
          onPressed: () {
            Get.back();
          },
          tooltip: MaterialLocalizations.of(context).backButtonTooltip, // 可选：设置工具提示
        ),
      ),
      body:  Container(
        padding: EdgeInsets.only(left: 20.w,right: 20.w,top: 4.w,bottom: 20.h),
        child: ListView(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  '请确保悟空已经开机',
                  style: TextStyle(fontSize: 48.sp,color: AppColors.Page_Title_Color),
                ),
              ],
            ),
            Container(
              margin: EdgeInsets.only(left: 70.w,top: 36.h),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    child: Text(
                      '1.开机过程需要60秒左右',
                      style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),
                    ),
                  ),
                  Container(
                    child: Text(
                      '2.当悟空说:"我已经准备好了"即开机成功',
                      style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color),
                    ),
                  )
                ],
              ),
            ),
            SizedBox(height: 177.h),
            Image.asset('assets/images/turn_on_robot.gif',width: 225.w,height: 553.h),
            SizedBox(height: 246.h),
            Obx(()=>Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                MSHCheckbox(
                  size: 40.w,
                  value: controller.checkbox_checked.value,
                  colorConfig: MSHColorConfig.fromCheckedUncheckedDisabled(
                    checkedColor: AppColors.Page_Title_Color,
                  ),
                  style: MSHCheckboxStyle.stroke,
                  onChanged: (selected) {
                    controller.checkbox_checked.value = selected;
                  },
                ),
                SizedBox(width: 20.w,),
                GestureDetector(
                  onTap: () {
                    controller.checkbox_checked.value = !controller.checkbox_checked.value;
                  },
                  child: Text('悟空已开机成功',style: TextStyle(fontSize: 28.sp,color: AppColors.newEditFieldHintText_color)),
                )

              ],
            )),
            SizedBox(height: 39.h),
            Obx(()=>ElevatedButton(onPressed: controller.checkbox_checked.value? () {
              if (!controller.checkbox_checked.value) {
                Tips.showToast('请确保机器人已经开机.');
                return;
              }
              controller.connectRobot();
            }:null, child: Text('下一步',style: TextStyle(fontSize: 25.sp),)))

          ],
        ),
      ),
    );
  }
}
